﻿using System;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace LeanApp.View
{
    /// <summary>
    /// AboutCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class AboutCtrl : UserControl
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public AboutCtrl()
        {
            InitializeComponent();
            Loaded += AboutCtrl_Loaded;
        }

        /// <summary>
        /// 关于窗体加载事件
        /// </summary>
        /// <param name="sender">事件对象</param>
        /// <param name="e">事件参数</param>
        private void AboutCtrl_Loaded(object sender, RoutedEventArgs e)
        {
            RefreshVersion();
        }

        /// <summary>
        /// 刷新版本号
        /// </summary>
        private void RefreshVersion()
        {
            txtVersion.Dispatcher.Invoke(() =>
            {
                Version version = Assembly.GetExecutingAssembly().GetName().Version;
                string versionTxt = "Beta v0." + version.Minor.ToString() + "." + version.Revision.ToString();
                versionTxt = versionTxt + " @ 2021 - ";
                versionTxt = versionTxt + DateTime.Now.Year.ToString();
                txtVersion.Text = versionTxt;
            });
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void About_MouseDown(object sender, MouseButtonEventArgs e)
        {
            _times++;
            if (_times % 31 == 0)
            {
                MessageBox.Show("Developer : Jowen Zhang\r\nTechnical Support : zjw1514@163.com");
                _times = 0;
            }
        }

        private static int _times = 0;
    }
}
